package org.student.impl;

import java.util.List;

import org.springframework.stereotype.Component;
import org.student.dao.IClassInfoDao;
import org.student.entity.StuSys_Arrange;
import org.student.entity.StuSys_ClassInfo;
import org.student.entity.StuSys_Student;
import org.student.entity.StuSys_Subject;

@Component("ClassInfoDaoImpl")
public class ClassInfoDaoImpl extends HibernateDaoImpl implements IClassInfoDao {

	@Override
	public void classInfoSave(StuSys_ClassInfo classInfo) throws Exception {
		super.save(classInfo);
	}

	@Override
	public StuSys_ClassInfo findClassInfoByClassId(int classId)
			throws Exception {
		return (StuSys_ClassInfo) super.get(StuSys_ClassInfo.class, classId);

	}

	@Override
	public List<StuSys_ClassInfo> findAllClassInfo() throws Exception {
		return (List<StuSys_ClassInfo>) super.getHibernateTemplate().find("from StuSys_ClassInfo");
	}

	@Override
	public List<StuSys_Arrange> getInfo(String keyWord) throws Exception {
		String hql = "FROM StuSys_Arrange where classRoom like '%"+keyWord+"%'" ;
		return this.find(hql) ;
	}

	@Override
	public List<StuSys_Subject> getSub(String keyword) throws Exception {
		String hql = "from StuSys_Subject where subName like '%"+keyword+"%'" ;
		return this.find(hql);
	}

	@Override
	public List<StuSys_ClassInfo> getInfoByKeyword(String keyword)
			throws Exception {
		String hql = "FROM StuSys_ClassInfo where className like '%"+keyword+"%' or manager like '%"+keyword+"%' or specialtyName like '%"+keyword+"%' " 
		+ " or insititueName like '%"+keyword+"%' or total like '%"+keyword+"%'" ;
		return this.find(hql);
	}

	@Override
	public void update_ClassInfo(StuSys_ClassInfo classInfo) throws Exception {
		this.update(classInfo) ;
	}

	@Override
	public StuSys_ClassInfo getClassInfoById(int id) throws Exception {
		return (StuSys_ClassInfo)this.get(StuSys_ClassInfo.class, id) ;
	}

}
